import axios from 'axios'
import * as constents from './constents'

const changeLogin = () => {
  return {
    type: constents.CHANGE_LOGIN,
    value: true
  }
}
export const login = (accout, password) => {
  return (dispatch) => {
    axios.get('/api/login.json?accout' + accout + '&password' + password).then(res => {
      const { data } = res.data
      if (data) {
        dispatch(changeLogin())

      } else {
        alert('登录失败')
      }
    })
  }
}


export const logout = () => {
  return {
    type: constents.LOGOUT,
    value: false
  }
}
